
import json
def response(flow):
    if 'api/sns/v10/search/notes' in flow.request.url:
        for content in json.loads(flow.response.text)['data']['items']:
            try:
                if content['model_type'] == 'note':
                    content_info = {}
                    content_info['note_id'] = content['note']['id']
                    content_info['note_title'] = content['note']['title']
                    content_info['note_desc'] = content['note']['desc']
                    content_info['note_liked'] = content['note']['liked_count']
                    content_info['note_nickname'] = content['note']['user']['nickname']
                    print(content_info)
                    with open('content_info.txt','a',encoding='utf-8')as f:
                        f.write(json.dumps(content_info,ensure_ascii=False))
                        f.write('\n')
            except:
                pass

